<script setup lang="ts">
import { ref } from "vue";
import { useLocalStore } from "@/views/report/device/store";
import { TYPE_LIST } from "@/views/report/device/constants";
const isShow = ref(true);

const activeTypeId = ref(null);
const store = useLocalStore();
const onClick = (data) => {
  store.setStatisticsConditionFromChart(null)
  store.showStatisticChart(false);
  activeTypeId.value = data.id;
  store.setStatisticsCategory(data.id);
};
onUnmounted(() => {
  activeTypeId.value = null;
  store.setStatisticsCategory(-1);
});
</script>

<template>
  <div class="thematic-map" v-if="isShow">
    <div class="title">专题展示</div>
    <div class="point-list">
      <div
        v-for="point in TYPE_LIST"
        :key="point.id"
        :class="{ active: point.id === activeTypeId }"
        @click="onClick(point)"
      >
        <span>{{ point.name }}</span>
        <el-icon class="check" v-if="point.id === activeTypeId"
          ><Check
        /></el-icon>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.thematic-map {
  position: absolute;
  top: 10px;
  left: 15px;
  z-index: 1000;
  width: 340px;
  height: 800px;
  font-family: Roboto, sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: rgb(16 16 16 / 100%);
  background-color: rgb(255 255 255 / 100%);
  //border: 1px solid rgb(25 144 255 / 100%);
  border-radius: 3px;
}

.title {
  height: 70px;
  font-size: 28px;
  font-weight: bold;
  line-height: 70px;
  text-align: center;
  border-bottom: 1px solid rgb(128 128 128 / 10%);
}

.pipe-category {
  height: 45px;
  padding-left: 20px;
  font-size: 16px;
  line-height: 45px;
  color: rgb(255 255 255 / 100%);
  background-color: rgb(25 144 255 / 100%);
  border: 1px solid rgb(255 255 255 / 100%);
  border-radius: 3px;
}

.point-list {
  height: 300px;
  overflow-y: auto;

  div {
    height: 40px;
    padding-left: 20px;
    margin: 10px 0;
    font-size: 16px;
    line-height: 40px;
    cursor: pointer;
    border-bottom: 1px solid rgb(128 128 128 / 10%);

    span {
      margin: 0 5px;
    }
  }

  .active {
    color: #0e30dc;
  }

  .check {
    position: relative;
    top: 10px;
    right: 10px;
    float: right;
  }
}
</style>
